import BaseInput from './BaseInput'

export default class PasswordInput extends BaseInput {
  constructor(props) {
    super(props)

    this.state = {
      icon: require('../../../../assets/img/login/pwd.png'),
      placeholder: '请输入密码',
      keyboardType: 'default',
      isSecure: true,
      showEye: true,
      clickEye: '', // 可视按钮的颜色
      eyeColor: false,
      showDelete: 'none',
      value: ''
    }
  }

  _validText = () => {
    let text = this.state.value
    return new Promise((resolve, reject) => {
      if (text.length === 0) {
        reject(new Error('密码不能为空'))
      } else if (text.indexOf(' ') > -1) {
        reject(new Error('密码不能包含空格'))
      } else if (text.length < 6 || text.length > 20) {
        reject(new Error('请输入密码(6-20位)'))
      } else {
        resolve(text)
      }
    })
  }
}
